<template>
  <div>
    <el-dialog
      title=""
      :visible.sync="dialogVisible"
      width="40%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="resetForm"
    >
      <el-descriptions
        title="详细信息"
        :column="2"
      >
        <el-descriptions-item label="站点名称">{{ ruleForm.site_name }}</el-descriptions-item>
        <el-descriptions-item label="设备序列号">{{ ruleForm.device_num }}</el-descriptions-item>
        <el-descriptions-item label="设备名称">{{ ruleForm.device_name }}</el-descriptions-item>
        <el-descriptions-item label="设备类型">{{ ruleForm.device_typename['name'] }}</el-descriptions-item>
        <el-descriptions-item label="安装时间">{{ ruleForm.install_time }}</el-descriptions-item>
        <el-descriptions-item label="安装地址">{{ ruleForm.address }}</el-descriptions-item>
        <el-descriptions-item label="IP">{{ ruleForm.ip }}</el-descriptions-item>
        <el-descriptions-item label="设备端口号">{{ ruleForm.device_port }}</el-descriptions-item>
        <el-descriptions-item label="设备用户名">{{ ruleForm.device_user }}</el-descriptions-item>
        <el-descriptions-item label="设备密码">{{ ruleForm.device_pass }}</el-descriptions-item>
        <el-descriptions-item :span="2" label="直播源地址1">{{ ruleForm.address1 }}</el-descriptions-item>
        <el-descriptions-item :span="2" label="直播源地址2">{{ ruleForm.address2 }}</el-descriptions-item>
      </el-descriptions>
      <div style="display: flex;justify-content: flex-end">
        <el-button type="primary" @click="resetForm" size='mini'>关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { detailVideoFile, stationAllList, getDictionary } from '@/api/fileManage'

export default {
  name: 'info',
  props: {
    id: {
      type: Number,
      default: 0
    },
    dialogVisible: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      optionsType: [],
      optionsSite: [],
      ruleForm: {}
    }
  },
  created() {
    this.getOptions()
  },
  methods: {
    // 获取详情
    getDetailById(id) {
      detailVideoFile({ id }).then(res => {
        this.ruleForm = res.data
        this.ruleForm.device_type += ''
      })
    },
    // 获取所有站点
    getOptions() {
      stationAllList().then(res => {
        // console.log('站点名称', res)
        this.optionsSite = res.data.data
      })
      getDictionary({
        pid: 8
      }).then(res => {
        this.optionsType = res.data.dictionaries
      }).then(() => {
        this.getDetailById(this.id)
      })
    },
    // 表单重置
    resetForm() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>

</style>
